Basic: Basic information
This module is the vehicle basic information module. This module is provided in EdgerOS 2.0.0 and later, and apps need to have vehicle.cockpit
permission to use this module.
User can use the following code to import the Basic
module.
var Basic = require('vehicle/basic');
Support
The following shows Basic
module APIs available for each permissions.
User Mode | Privilege Mode | |
---|---|---|
Basic | ● | ● |
basic.request | ● | ● |
basic.release | ● | ● |
basic.chassis | ● | ● |
basic.vehicle | ● | ● |
basic.geolocation | ● | ● |
basic.suspension | ● | ● |
chassis.info | ● | ● |
chassis.drive | ● | ● |
chassis.power | ● | ● |
vehicle.status | ● | ● |
vehicle.gear | ● | ● |
vehicle.epb | ● | ● |
vehicle.steering | ● | ● |
geolocation.mode | ● | |
geolocation.location | ● | ● |
suspension.airspring | ● | ● |
suspension.cdc | ● | ● |
suspension.style | ● | ● |
suspension.status | ● | ● |
Basic Class
new Basic()
- Returns: {Object} Basic object.
Create a basic object.
Basic Object
basic.request(callback)
callback
{Function} Callback.error
{Error} Specify the error message when the request is failed.
Request for vehicle basic information acquire. After the request is successful, the vehicle basic information can be obtained.
basic.release()
Release the current basic object, no operation is allowed after the object is released.
The object needs to be released as soon as possible when it is no longer used.
basic.chassis
- {Object}
Get basic chassis object.
basic.vehicle
- {Object}
Get basic vehicle object.
basic.geolocation
- {Object}
Get basic geolocation object.
basic.suspension
- {Object}
Get basic suspension object.
Chassis Object
chassis.info(callback)
callback
{Function} Callback.error
{Error} Specify the error message when failed.info
{Object} Chassis information.
Get chassis information. The info
object contains the following members:
Member | Type | Description |
---|---|---|
pmmSysSt | Integer | 0 : INIT 1 : LVPWRUP 2 : HVPWRUP 3 : NORMAL 4 : TMOUT 5 : PWRDWN |
readyLightSt | Integer | Ready light 0 : OFF 1 : ON |
odometer | Integer | Total kilometers traveled |
residualOdometer | Integer | Residual kilometers |
energyConsumption | Integer | Average consumption per 100 kilometers. |
Example
var Basic = require('vehicle/basic');
var basic = new Basic();
var chassis = basic.chassis;
basic.request(error => {
if (error == undefined) {
chassis.info((error, info) => {
if (info) {
console.log(info);
}
});
}
});
chassis.drive(callback)
callback
{Function} Callback.error
{Error} Specify the error message when failed.drive
{Object} Chassis drive information.
Get chassis drive information. The drive
object contains the following members:
Member | Type | Description |
---|---|---|
accel | Integer | Accelerator pedal position (0 - 100 ) |
brake | Integer | Brake pedal position (0 - 100 ) |
steering | Integer | Steering wheel rotation (-780 R - 780 L) |
chassis.power(callback)
callback
{Function} Callback.error
{Error} Specify the error message when failed.power
{Object} Chassis power information.
Get chassis power information. The power
object contains the following members:
Member | Type | Description |
---|---|---|
residual | Integer | Residual power 0 - 100 % |
energy | Integer | Residual energy (Kwh) |
health | Integer | Battery health 0 - 100 % |
discharge | Integer | Discharge power (Kw) |
workingMode | Integer | 0 : No mode 1 : Standby 2 : Discharge 3 : AC charging 4 : DC charging 5 : External discharge 6 : Battery warm 7 : Power off cooling 8 : Boost Charging 9 : Battery self-heating |
chargeState | Integer | 0 : Normal 1 : Slow Charging 2 : Fast Charging 3 : Heating 4 : Heating while Charging 5 : Heart Preservation 6 : Charge Stop 7 : Charge Fault 8 : Charge Achieved |
Chassis Object Events
The chassis
object inherits from the EventEmitter
class. The following events are thrown in some specific situations.
info
This event is emitted when info
is updated.
Example
chassis.on('info', (info) => {
console.log(info);
});
drive
This event is emitted when drive
is updated.
Example
chassis.on('drive', (drive) => {
console.log(drive);
});
power
This event is emitted when power
is updated.
Example
chassis.on('power', (power) => {
console.log(power);
});
Vehicle Object
vehicle.status(callback)
callback
{Function} Callback.error
{Error} Specify the error message when failed.status
{Object} Vehicle status.
Get basic vehicle status. The status
object contains the following members:
Member | Type | Description |
---|---|---|
speed | Integer | Current speed |
instPowerConsum | Integer | Instantaneous energy consumption (Kwh) |
acAnionSt | Integer | 0 : OFF 1 : ON |
accLatVeh | Integer | Lateral acceleration |
accLonVeh | Integer | Longitudinal acceleration |
accVertVeh | Integer | Vertical acceleration |
vehicle.gear(callback)
callback
{Function} Callback.error
{Error} Specify the error message when failed.gear
{Object} Gear status.
Get basic vehicle gear status. The gear
object contains the following members:
Member | Type | Description |
---|---|---|
pos | String | Current gear: 'P' |'R' |'N' |'D' |'S' |
vehicle.epb(callback)
callback
{Function} Callback.error
{Error} Specify the error message when failed.epb
{Object} EPB status.
Get basic vehicle Electronic Parking Brake status. The epb
object contains the following members:
Member | Type | Description |
---|---|---|
status | Integer | 1 : Released 2 : Clamped 3 : Clamping 4 : Releasing 5 : Dynamic braking via EPB 6 : Full Released |
vehicle.steering(callback)
callback
{Function} Callback.error
{Error} Specify the error message when failed.steering
{Object} Tire steering status.
Get vehicle body and tire steering information. The steering
object contains the following members:
awsAngle
{Number} Front wheel steering angle.rwsAngle
{Number} Rear wheel steering angle.diameterDiff
{Number} Turning diameter difference.diameterDiffPcnt
{Number} Turning diameter difference percentage.
Vehicle Object Events
The vehicle
object inherits from the EventEmitter
class. The following events are thrown in some specific situations.
status
This event is emitted when status
is updated.
Example
vehicle.on('status', (status) => {
console.log(status);
});
gear
This event is emitted when gear
is changed.
Example
vehicle.on('gear', (gear) => {
console.log(gear);
});
epb
This event is emitted when epb
is changed.
Example
vehicle.on('epb', (epb) => {
console.log(epb);
});
steering
This event is emitted when steering
is changed.
Example
vehicle.on('steering', (steering) => {
console.log(steering);
});
Geolocation Object
geolocation.mode([mode, ]callback)
mode
{String} GPS mode to be set.callback
{Function} Callback.error
{Error} Specify the error message when failed.mode
{String} If it is get, it indicates the current GPS mode.
Set or get the current GPS mode. Possible mode include:
'independent'
Independent use of satellite positioning systems.'msb'
: Mobile Station Based.'msa'
: Mobile Station Assisted.'fast'
: Obtain positioning information as quickly as possible.
This method can only be used by privileged applications. This setting is a persistent setting.
geolocation.location(callback)
callback
{Function} Callback.error
{Error} Specify the error message when failed.location
{Object} Last location information.
Get last location information. location
includes the following members:
lat
{Number} Latitude.lon
{Number} Longitude.alt
{Number} Altitude.
App must have vehicle.geolocation
permission.
Geolocation Object Events
The Geolocation
object inherits from the EventEmitter
class. The following events are thrown in some specific situations.
nmea
This event is emitted when position is updated. Comprehensive NMEA standards compliant positioning information is available here. This message parameter is a parsed object, please refer to: https://www.npmjs.com/package/gps
Example
const GPS = require('gps');
// Add an event listener on all protocols
gps.on('data', parsed => {
console.log(JSON.stringify(parsed));
});
// Update position information
geolocation.on('nmea', nmea => {
gps.update(nmea.raw);
});
Suspension Object
suspension.airspring([param, ]callback)
param
{Object} Parameters.callback
{Function} Callback.error
{Error} Specify the error message when failed.param
{Object} If it is get, it indicates the current airspring settings.
Set or get the current suspension airspring settings.
suspension.cdc([param, ]callback)
param
{Object} Parameters.callback
{Function} Callback.error
{Error} Specify the error message when failed.param
{Object} If it is get, it indicates the current CDC settings.
Set or get the current suspension CDC settings.
suspension.style([param, ]callback)
param
{Object} Parameters.callback
{Function} Callback.error
{Error} Specify the error message when failed.param
{Object} If it is get, it indicates the current style settings.
Set or get the current suspension style settings.
suspension.status(callback)
callback
{Function} Callback.error
{Error} Specify the error message when failed.status
{Object} Indicates the current suspension status.
Get the current suspension status.
Suspension Object Events
The Suspension
object inherits from the EventEmitter
class. The following events are thrown in some specific situations.
airspring
param
{Object}
cdc
param
{Object}
style
param
{Object}
status
param
{Object}